package j.k.kim.ftp.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtility {
	private static SimpleDateFormat formatter = new SimpleDateFormat(
			"yyyy-MM-dd");

	private DateUtility() {
	}

	public static Date getToday() {
		Calendar c = Calendar.getInstance();
		return c.getTime();
	}

	public static Date getAddedDateFromToday(int add) {
		Date d = getToday();
		d.setDate(d.getDate() + add);
		return d;
	}

	public static boolean isSameDate(Date d1, Date d2) {
		String str1 = formatter.format(d1);
		String str2 = formatter.format(d2);
		return str1.equals(str2);
	}

	public static String getDateString(Date d) {
		return formatter.format(d);
	}

	public static Date getDate(String str) throws ParseException {
		return formatter.parse(str);
	}
}
